<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title> 

</head>
<jsp:include page="../default.jsp" />
<body>
	<div class="mini-fit">
		<div id="form" align="center">		
			<table align="center" width="100%" border="0" cellpadding="0" cellspacing="0">
				<tr height="30px">
				   <td align="right">旧密码：</td>
				   <td>
				       <input name="originPassword" class="mini-password" vtype="letterAndNumber;minLength:6;maxLength:10;" required="true"/>
				   </td>
				   <td align="right">新密码：</td>
				   <td>
				       <input name="password" class="mini-password" vtype="letterAndNumber;minLength:6;maxLength:10;" required="true"/>
				   </td>
				</tr>
				<tr height="30px">
				   <td align="right">新密码（重复）：</td>
				   <td>
				       <input name="passwordRepet" class="mini-password" vtype="letterAndNumber;minLength:6;maxLength:10;" required="true"/>
				   </td>
				   <td align="right"></td>
				   <td></td>
				</tr>
			</table>			
		</div>
	</div>
	<div class="mini-toolbar" style="text-align: center; border-bottom:0;border-left:0;border-right:0;">		
		<a class="mini-button" iconCls="icon-save" onclick="save()" id="saveBtn">保存</a>
		<a class="mini-button" iconCls="icon-close" onclick="CommonUtil.prototype.closeWindow('ignore');">关闭</a>
	</div>
    <script type="text/javascript">
    	mini.parse();
    	var form = new mini.Form("#form");
    	
    	function save(){
    		form.validate();
            if (form.isValid() == false) return;
            var data = form.getData(true);
            if(data.password != data.passwordRepet){
            	mini.alert("新密码两次输入的不一致");
            	return;
            }
            if(data.password == data.originPassword){
            	mini.alert("新密码不能和原密码相同");
            	return;
            }
            CommonUtil.prototype.mask();
            $.ajax({
				url : "${pageContext.request.contextPath}/system/editPassword.do",
				data : data,
				type : "POST",
				dataType : "json",
				success : function(data, textStatus, jqXHR) {
					CommonUtil.prototype.unmask();
					if(data.success){
						mini.alert("修改成功", "提醒", function(){
							CommonUtil.prototype.closeWindow('ignore');
						});
					}				
				}
			});	
    	}   	
	</script>
  </body>
</html>
